package com.quick.springbootquicky.mapper;

import com.quick.springbootquicky.pojo.TestUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


@Mapper//@Repository、@Service、@Controller、@Component
public interface TestUserMapper {
    @Select("select * from test_user where username= #{id}")
    public TestUser findByUserName(String username);

    @Insert("insert into test_user (username,password,create_time,update_time) " +
            " values(#{username},#{password},now(),now())")
    public int add(String username,String password);

    @Update("update  test_user set nickname=#{nickname},email=#{email},update_time=#{updateTime},phone=#{phone},age=#{age} where id=#{id}")
    void updateUser(TestUser user);

    @Update("update  test_user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
    void updateAvatar(String avatarUrl, Integer id);

    @Update("update  test_user set password=#{password},update_time=now() where id=#{id}")
    void updatePwd(String password, Integer id);
}
